/**
 * @desc 重试函数的调用方法，可以重新处理逻辑
 * @param {*} requestFunction 
 * @param {*} retries 
 * @param {*} delay 
 */
export const retryRequest = function(requestFunction,retries = 3,delay=5000){
    
    return new Promise((resolve,reject)=>{
        requestFunction()
            .then(resolve)
            .catch(error=>{
                console.log("错误信息报错提示",error);
                if(retries>0){
                    console.log("重试次数",retries);
                    setTimeout(()=>{
                        retryRequest(requestFunction,retries-1).then(resolve,reject);
                    },delay)
                }else{
                    console.log("您的重试次数已经用完了")
                    //次数用完了继续抛出错误信息
                    reject(error)
                }
            })
    })
}